#!/bin/sh

pnicore_install()
{
    cd libpnicore
    scons PREFIX=$PREFIX doc install -j$NCPUS
    cd ..
}

pniio_install()
{
    cd libpniio
    scons PREFIX=$PREFIX doc install -j$NCPUS
    cd ..
}


#need to handle command line options
SOPTS="p:dj:"
LOPTS="prefix:,debug,ncores:"

ARGS=`getopt -o$SOPTS -l$LOPTS -n"build.sh" -- "$@"`

eval set -- $ARGS

PREFIX=/usr/local
NCPUS=1
DEBUG=0

while true; do
case "$1" in

    -p|--prefix) 
        echo "prefix is $2"
        PREFIX=$2
        shift 2
         ;;
    -d|--debug)
        echo "with debugging options - on"
        DEBUG=1
        shift 1
        ;;
    -j|--ncores)
        echo "use $2 number of cpus for build"
        NCPUS=$2
        shift 2
        ;;
    --) shift 1 
        break 
        ;;
esac
done

#set the pkg-config path variable
PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig

echo "install code ..."
echo "Using $NCPUS processors ..."
pnicore_install
pniio_install


#building libpnicore
